Network Device

ABSTRACT

This application provides a network device, including a buffer module, a counting module, a control module, and a sending module. The buffer module includes N queues, configured to buffer M data streams, where N is less than M. The counting module includes M counters, the M counters are in a one-to-one correspondence with the M data streams, and the M counters are configured to count buffer quantities for the M data streams in the N queues. The control module is configured to: when a count value on a first counter exceeds a corresponding threshold, discard a to-be-enqueued data packet of a data stream corresponding to the first counter, or control the sending module to send pause indication information to an upper-level control module. On one hand, resource consumption of the network device can be reduced. On the other hand, buffer pressure of the network device can be released.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No. PCT/CN2018/087286, filed on May 17, 2018, which claims priority to Chinese Patent Application No. 201710680143.5, filed on Aug. 10, 2017. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

This application relates to the field of communications technologies, and in particular, to a network device.

BACKGROUND

The Internet provides a data transmission channel between network devices. Each data sequence transmitted between network devices may be referred to as a data stream. The network device may be a switch, a router, a switching chip, or the like.

In the prior art, a network device allocates different queues to different data streams. For example, the network device allocates different queues to data streams transmitted to other different network devices or allocates different queues to data streams in different services. Each queue occupies a fixed available space, and when a space of one queue is used up, other queues still have a sufficient space for use. As a network speed rapidly increases, a quantity of data streams in the network device is also increased rapidly. To isolate different data streams to avoid them from affecting each other, a quantity of required queues is also sharply increased. However, on one hand, a queue is usually in a form of a linked list, and a larger quantity of queues leads to higher logical complexity of the linked list. This causes excessively high resource consumption of the network device. On the other hand, a sharp increase in the quantity of queues poses a greater challenge to buffering in the network device.

SUMMARY

This application provides a network device. On one hand, resource consumption of the network device can be reduced. On the other hand, buffer pressure of the network device can be released.

This application provides a network device, including a buffer module, a counting module, a control module, and a sending module. The buffer module includes N queues, configured to buffer M data streams, where N is less than M. The counting module includes M counters, the M counters are in a one-to-one correspondence with the M data streams, and the M counters are configured to count buffer quantities for the M data streams in the N queues. The control module is configured to: when a count value on a first counter exceeds a corresponding threshold, discard a to-be-enqueued data packet of a data stream corresponding to the first counter, or control the sending module to send pause indication information to an upper-level control module, where the pause indication information is used to instruct the upper-level control module to pause data packet sending. The first counter is any one of the M counters.

To be specific, once the count value on the first counter exceeds the corresponding threshold, the to-be-enqueued data packet of the data stream corresponding to the first counter is discarded, or the sending module is controlled to send the pause indication information to the upper-level control module. On one hand, resource consumption of the network device can be reduced. On the other hand, buffer pressure of the network device can be released.

Optionally, the control module is further configured to: when the count value on the first counter is less than the corresponding threshold, insert the to-be-enqueued data packet into a corresponding queue, and control the first counter to update the count value.

Optionally, the first counter is specifically configured to calculate a weighted average value of the count value and a length of the to-be-enqueued data packet, to obtain an updated count value on the first counter.

To be specific, the network device can accurately update a count value on each counter, to accurately determine whether the count value on each counter is less than a corresponding threshold, so as to determine whether to discard a to-be-enqueued data packet or send pause indication information to an upper-level control module.

Optionally, the control module is further configured to schedule a data packet in any queue, and control a second counter corresponding to the scheduled data packet to update a count value.

Optionally, the second counter is specifically configured to calculate a difference between the count value on the second counter and a length of the scheduled data packet, to obtain an updated count value on the second counter.

Optionally, the N queues are N input queues, and the M data streams are M input data streams. Correspondingly, the control module is further configured to set the N input queues based on a quantity of input ports of the network device and a maximum quantity of queues that corresponds to each input port.

Optionally, the control module is further configured to: determine a maximum quantity M of input data streams based on a quantity of users that corresponds to each input port and a maximum quantity of data streams that corresponds to each user; and group input data packets into the M input data streams.

In this application, the network device serving as a lower-level network device can accurately set the input queues and the number of input data streams M.

Optionally, the N queues are N output queues, and the M data streams are M output data streams. Correspondingly, the control module is further configured to set the N output queues based on a quantity of lower-level network devices.

Optionally, the control module is further configured to: determine a maximum quantity M of output data streams based on the quantity of lower-level network devices, a maximum quantity of input ports of each lower-level network device, and a maximum quantity of data streams that corresponds to each input port of the lower-level network device; and group output data packets into the M output data streams.

In this application, the network device serving as an upper-level network device can accurately set the output queues and the number of output data streams M.

This application provides a network device, including a buffer module, a counting module, a control module, and a sending module. The buffer module includes N queues, configured to buffer M data streams, where N is less than M. The counting module includes M counters, the M counters are in a one-to-one correspondence with the M data streams, and the M counters are configured to count buffer quantities for the M data streams in the N queues. The control module is configured to: when a count value on a first counter exceeds a corresponding threshold, discard a to-be-enqueued data packet of a data stream corresponding to the first counter, or control the sending module to send pause indication information to an upper-level control module. It is not common that there are a huge quantity of data streams at a same moment. Therefore, in this application, in this case, it is proper to set a quantity of queues to be less than the quantity of data streams. Because the quantity of queues included in the network device provided in this application is few, resource consumption of the network device can be reduced, and buffer pressure of the network device can be released. For a short-time burst, that is, when there are a huge quantity of data streams at a same moment, once a count value on a counter exceeds a corresponding threshold, the control module discards a to-be-enqueued data packet of a data stream corresponding to the counter, or controls the sending module to send pause indication information to an upper-level control module. Based on this, the network device can buffer the M data streams through the N queues, thereby reducing resource consumption of the network device and releasing buffer pressure of the network device.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is an application scenario diagram according to an embodiment of this application;

FIG. 2 is a schematic structural diagram of a network device according to an embodiment of this application; and

FIG. 3 is a schematic structural diagram of a network device according to an embodiment of this application.

DESCRIPTION OF EMBODIMENTS

This application provides a network device. The network device may be a switch, a router, a switching chip, or the like.

The switching chip is used as an example. FIG. 1 is an application scenario diagram according to an embodiment of this application. As shown in FIG. 1, one switching chip may have at least one upper-level switching chip and at least one lower-level switching chip. The switching chip may serve as both an upper-level switching chip and a lower-level switching chip. When the switching chip serves as an upper-level switching chip, the upper-level switching chip sends a data packet to a lower-level switching chip of the upper-level switching chip through an output port. When the switching chip serves as a lower-level switching chip, the lower-level switching chip receives, through an input port, a data packet sent by an upper-level switching chip of the lower-level switching chip. When the switching chip serves as an upper-level switching chip, the upper-level switching chip needs to set a queue used to store a to-be-sent data stream. The queue used to store the to-be-sent data stream is referred to as an output queue. When the switching chip serves as a lower-level switching chip, the lower-level switching chip needs to set a queue used to store a received data stream. The queue used to store the received data stream is referred to as an input queue.

Similarly, a switch may serve as both an upper-level switch and a lower-level switch. When the switch serves as an upper-level switch, the upper-level switch sends a data packet to a lower-level switch through an output port. When the switch serves as a lower-level switch, the lower-level switch receives, through an input port, a data packet sent by an upper-level switch of the lower-level switch. When the switch serves as an upper-level switch, the upper-level switch needs to set an output queue. When the switch serves as a lower-level switch, the lower-level switch needs to set an input queue.

Similarly, a router may serve as both an upper-level router and a lower-level router. When the router serves as an upper-level router, the upper-level router sends a data packet to a lower-level router through an output port. When the router serves as a lower-level router, the lower-level router receives, through an input port, a data packet sent by an upper-level router of the lower-level router. When the router serves as an upper-level router, the upper-level router needs to set an output queue. When the router serves as a lower-level router, the lower-level router needs to set an input queue.

This application provides a network device to resolve the following technical problems in the prior art: On one hand, a queue is usually in a form of a linked list, and a larger quantity of queues leads to higher logical complexity of the linked list. This causes excessively high resource consumption of the network device. On the other hand, a sharp increase in the quantity of queues poses a greater challenge to buffering in the network device. The queue may be the input queue or the output queue described above.

Specifically, FIG. 2 is a schematic structural diagram of a network device according to an embodiment of this application. As shown in FIG. 2, the network device includes a buffer module 21, a counting module 22, a control module 23, and a sending module 24. The buffer module 21 includes N queues, configured to buffer M data streams, where N is less than M. The counting module 22 includes M counters, the M counters are in a one-to-one correspondence with the M data streams, and the M counters are configured to count buffer quantities for the M data streams in the N queues. The control module 23 is configured to: when a count value on a first counter exceeds a corresponding threshold, discard a to-be-enqueued data packet of a data stream corresponding to the first counter, or control the sending module 24 to send pause indication information to an upper-level control module 25, where the pause indication information is used to instruct the upper-level control module 25 to pause data packet sending. The first counter is any one of the M counters.

The N queues may be N input queues. Correspondingly, the M data streams are M input data streams. In this case, the network device may be understood as a lower-level network device. The N queues may be N output queues. Correspondingly, the M data streams are M output data streams. In this case, the network device may be understood as an upper-level network device.

Optionally, the M counters are not fixedly allocated to the data streams, but are dynamically allocated to the data streams. A specific dynamic allocation algorithm may be any dynamic allocation algorithm in the prior art, provided that the M counters are in a one-to-one correspondence with the M data streams. This application is not limited thereto.

Each of the M counters is configured to count a buffer quantity for a corresponding data stream in a queue corresponding to the data stream. For example, a buffer quantity for a data stream B in a queue Q counted by a counter A is a length of the data stream B. When a data packet C is added to the data stream B, the buffer quantity for the data stream B in the queue Q counted by the counter A is a sum of the length of the data stream B and a length of the data packet C. Alternatively, when a data packet C is added to the data stream B, the buffer quantity for the data stream B in the queue Q counted by the counter A is a weighted average value of the length of the data stream B and a length of the data packet C. Alternatively, the buffer quantity for the data stream B in the queue Q counted by the counter A is a quantity of data packets included in the data stream B. Each counter has a corresponding threshold. Corresponding thresholds of the M counters may be the same or different.

The upper-level control module 25 and the control module 23 may belong to a same network device or belong to different network devices. For example, the upper-level control module 25 and the control module 23 may be two control modules belonging to a same switching chip, or the upper-level control module 25 and the control module 23 may belong to different switching chips. This application is not limited thereto. In FIG. 1, that the upper-level control module 25 and the control module 23 belong to different network devices is used as an example.

Optionally, the buffer module 21 may be a buffer, and the buffer may be a buffer in a random access memory (random access memory, RAM), a memory module, an integrated circuit, or the like. This embodiment of this application is not limited thereto.

The control module 23 may be an integrated circuit in a switching chip, a processor or a controller in a switch, a processor or a controller in a router, or the like. The control module 23 may be connected to the buffer module 21, the counting module 22, and the sending module 24 by using a CAN bus. In addition, the control module 23 may be connected to the upper-level control module or a lower-level control module by using a public interface or a private interface, thereby communicating with the upper-level control module and the lower-level control module. The public interface may be an Ethernet (Ethernet) interface or the like, and the private interface may be a source-based (Cell-based) interface or the like.

The sending module 24 may be an integrated circuit in a switching chip, a transmitter in a switch, a transmitter in a router, or the like.

For example, FIG. 3 is a schematic structural diagram of a network device according to an embodiment of this application. As shown in FIG. 3, it is assumed that the network device is a switching chip. The current level of switching chip has a plurality of upper-level switching chips. Each switching chip includes an integrated circuit 31 configured to buffer a queue, a counting module 32 including M counters, an integrated circuit 34 configured to send pause indication information to an upper-level integrated circuit 33 (corresponding to the foregoing upper-level control module), and an integrated circuit 35 configured to discard a to-be-enqueued data packet or configured to control the integrated circuit 34 to send the pause indication information to the upper-level integrated circuit 33.

The integrated circuit 31 includes N queues, configured to buffer M data streams, where N is less than M. The counting module 32 includes M counters 321, the M counters 321 are in a one-to-one correspondence with the M data streams, and the M counters 321 are configured to count buffer quantities for the M data streams in the N queues.

The integrated circuit 35 may be connected to the integrated circuit 31, the counting module 32, and the integrated circuit 34 by using a CAN bus. The integrated circuit 35 is connected to the upper-level integrated circuit 33 by using a source-based (Cell-based) interface.

Further, as a network speed rapidly increases, a quantity of data streams in the network device is also increased rapidly. However, it is not common that there are a huge quantity of data streams at a same moment. Particularly, for a data center, a switch is under light load in most time, and a burst occurs only for a short time. Therefore, in this application, in this case, it is proper to set a quantity of queues to be less than the quantity of data streams. In addition, because there are few queues, resource consumption of the network device can be reduced, and buffer pressure of the network device can be released.

For a short-time burst, that is, when there are a huge quantity of data streams at a same moment, the control module of the network device can determine, depending on whether a count value on a counter exceeds a corresponding threshold, whether to send pause indication information to the upper-level control module or discard a to-be-enqueued data packet. Once a count value on a counter exceeds a corresponding threshold, the control module discards a to-be-enqueued data packet of a data stream corresponding to the counter, or controls the sending module to send pause indication information to the upper-level control module. Sending the pause indication information to the upper-level control module embodies a hierarchical queue management mechanism. Usually, the control module has a plurality of upper-level control modules. Based on the hierarchical queue management mechanism, the plurality of upper-level control modules are enabled to share buffer pressure of the current level of control module. In conclusion, this application is applicable not only to a case in which a quantity of data streams is normal, but also to a case in which there are a huge quantity of data streams at a same moment. According to the network device provided in this application, on one hand, resource consumption of the network device can be reduced, and on the other hand, buffer pressure of the network device can be released.

In conclusion, this application provides the network device, including the buffer module, the counting module, the control module, and the sending module. The buffer module includes the N queues, configured to buffer the M data streams, where N is less than M. The counting module includes the M counters, the M counters are in a one-to-one correspondence with the M data streams, and the M counters are configured to count buffer quantities for the M data streams in the N queues. The control module is configured to: when the count value on the first counter exceeds the corresponding threshold, discard a to-be-enqueued data packet of a data stream corresponding to the first counter, or control the sending module to send pause indication information to the upper-level control module. On one hand, resource consumption of the network device can be reduced. On the other hand, buffer pressure of the network device can be released. Further, that the sending module sends pause indication information to the upper-level control module can be understood as a hierarchical implementation. When a plurality of upper-level network devices output data streams to the current level of network device, and congestion occurs in the current level of network device, the upper-level control module is caused, through the hierarchical implementation, to pause data packet sending. That is, the plurality of upper-level network devices can share congestion pressure of the current level of network device.

Optionally, the control module 23 is further configured to: when the count value on the first counter is less than the corresponding threshold, insert the to-be-enqueued data packet into a corresponding queue, and control the first counter to update the count value.

Optionally, the first counter is specifically configured to calculate a weighted average value of the count value and a length of the to-be-enqueued data packet, to obtain an updated count value on the first counter.

For example, the first counter C₁ may update a count value by using the following formula:

C _(1 new)=(1−α)×C _(1 old)+α×packet 1_length

where α is a smoothing factor, 0≤α≤1, C_(1_old) represents the count value before the update by the first counter C₁, C_(1_new) represents a count value after the update by the first counter C₁, and packet 1_length represents a length of a to-be-enqueued data packet.

Alternatively, the first counter may directly calculate a sum of the count value and a length of the to-be-enqueued data packet, to obtain an updated count value on the first counter. This application imposes no limitation on a method for calculating the updated count value.

The network device can accurately update a count value on each counter, to accurately determine whether the count value on each counter is less than a corresponding threshold, so as to determine whether to discard a to-be-enqueued data packet or send pause indication information to the upper-level control module.

Optionally, the control module 23 is further configured to schedule a data packet in any queue, and control a second counter corresponding to the scheduled data packet to update a count value.

Optionally, the second counter is specifically configured to calculate a difference between the count value on the second counter and a length of the scheduled data packet, to obtain an updated count value on the second counter.

The second counter may be none of the M counters. That is, the second counter and the M counters are disposed independently. In this case, the count value on the second counter and count values on the M counters are not mutually affected. The second counter may be any one of the M counters. For example, the second counter is the first counter. In this case, the count value on the first counter changes with scheduling of a data packet. For example, a current count value on the first counter C₁ is C_(1_new). When the scheduled data packet corresponds to the first counter C₁, C_(1_new)=C_(1_new)−packet 2_length, where C_(1_new) ′ represents a count value updated by the first counter C₁ based on the scheduled data packet, and packet 2_length represents a length of the scheduled data packet.

Optionally, when the N queues are N input queues and the M data streams are M input data streams, the control module 23 is further configured to set the N input queues based on a quantity of input ports of the network device and a maximum quantity of queues that corresponds to each input port.

Optionally, when the N queues are N input queues and the M data streams are M input data streams, the control module 23 is further configured to: determine a maximum quantity M of input data streams based on a quantity of users that corresponds to each input port and a maximum quantity of data streams that corresponds to each user; and group input data packets into the M input data streams.

Specifically, when the N queues are N input queues and the M data streams are M input data streams, it represents that the network device currently serves as a lower-level network device. In this case, the control module 23 may set the N input queues based on the quantity of input ports of the network device and the maximum quantity of queues that corresponds to each input port. Maximum quantities of queues that correspond to the input ports may be the same or different. It is assumed that a quantity of input ports of the network device is 5. Maximum quantities of queues of the input ports are the same, and each are 10. It is calculated that a product of the quantity of input ports of the network device and the maximum quantity of queues of each input port is 50. Based on this, the control module 23 may set 50 input queues.

Further, quantities of users that correspond to the input ports may be the same or different. Maximum quantities of data streams that correspond to the users may also be the same or different. It is assumed that the quantities of users that correspond to the input ports each are 100, and the maximum quantities of data streams that correspond to the users each are 5. In this case, a product of the quantity of users that corresponds to each input port and a maximum quantity of data streams that corresponds to each user is calculated to determine that the maximum quantity M of input data streams is 500.

Optionally, when the N queues are N output queues and the M data streams are M output data streams, the control module 23 is further configured to set the N output queues based on a quantity of lower-level network devices.

Optionally, when the N queues are N output queues and the M data streams are M output data streams, the control module 23 is further configured to: determine a maximum quantity M of output data streams based on the quantity of lower-level network devices, a maximum quantity of input ports of each lower-level network device, and a maximum quantity of data streams that corresponds to each input port of the lower-level network device; and group output data packets into the M output data streams.

Specifically, when the N queues are N output queues and the M data streams are M output data streams, it represents that the network device currently serves as an upper-level network device. In this case, the control module 23 may set the N output queues based on the quantity of lower-level network devices. For example, the quantity of lower-level network devices of the control module is 10. Based on this, the control module 23 may set 10 output queues. That is, a quantity of output queues is the same as the quantity of lower-level network devices. The control module 23 may further set the N output queues based on the quantity of lower-level network devices and an adjustment factor. The adjustment factor is a positive integer greater than 1. For example, if the quantity of lower-level network devices of the control module is 10, and the adjustment factor is 3, the control module 23 may calculate a product of the quantity 10 of the lower-level network devices and the adjustment factor 3, to obtain that N is 30. Therefore, the control module 23 may set 30 output queues.

Further, maximum quantities of input ports of the lower-level network devices may be the same or different, and maximum quantities of data streams that correspond to the input ports of the lower-level network devices may be the same or different. It is assumed that the quantity of lower-level network devices of the network device is 10, the maximum quantity of input ports of each lower-level network device is 3, and the maximum quantity of data streams that corresponds to each input port is 10. In this case, a product of the quantity of lower-level network devices, the maximum quantity of input ports of each lower-level network device, and the maximum quantity of data streams that corresponds to each input port is calculated, to obtain that the maximum quantity M of the output data streams is 300.

It should be noted that criteria of grouping data streams when the network device serves as an upper-level network device and serves as a lower-level network device in this application may be different. For example, the data streams may be grouped based on a lower-level network device and an input port of the lower-level network device when the network device serves as an upper-level network device. For example, the data streams may be grouped based on a quantity of lower-level network devices and input ports of the lower-level network devices when the network device serves as an upper-level network device. The data streams may be grouped based on a quintuple when the network device serves as a lower-level network device. The quintuple includes a source Internet (Internet Protocol, IP for short) address, a source port, a destination IP address, a destination port, and a transport layer protocol. Alternatively, the data streams may be grouped based on a quintuple when the network device serves as an upper-level network device. The data streams may be grouped based on a quantity of upper-level network devices and output ports of the upper-level network devices when the network device serves as a lower-level network device.

In conclusion, in this application, the network device serving as a lower-level network device can accurately set the input queues and the M input data streams. The network device serving as an upper-level network device can accurately set the output queues and the number of output data streams M. 

What is claimed is:
 1. A network device, comprising a buffer, a counting module, a controller, and a transmitter, wherein the buffer comprises N queues, configured to buffer M data streams, wherein N is less than M; the counting module comprises M counters, the M counters are in a one-to-one correspondence with the M data streams, and the M counters are configured to count buffer quantities for the M data streams in the N queues; and the controller is configured to: when a count value on a first counter exceeds a corresponding threshold, control the transmitter to send pause indication information to an upper-level controller, wherein the pause indication information is used to instruct the upper-level controller to pause data packet sending, wherein the first counter is any one of the M counters.
 2. The network device according to claim 1, wherein the controller is further configured to: when the count value on the first counter is less than the corresponding threshold, insert the to-be-enqueued data packet into a corresponding queue, and control the first counter to update the count value.
 3. The network device according to claim 1, wherein the first counter is specifically configured to calculate a weighted average value of the count value and a length of the to-be-enqueued data packet, to obtain an updated count value on the first counter.
 4. The network device according to claim 1, wherein the controller is further configured to schedule a data packet in any queue, and control a second counter corresponding to the scheduled data packet to update a count value.
 5. The network device according to claim 4, wherein the second counter is specifically configured to calculate a difference between the count value on the second counter and a length of the scheduled data packet, to obtain an updated count value on the second counter.
 6. The network device according to claim 1, wherein the N queues are N input queues, and the M data streams are M input data streams; and correspondingly, the controller is further configured to set the N input queues based on a quantity of input ports of the network device and a maximum quantity of queues that corresponds to each input port.
 7. The network device according to claim 6, wherein the controller is further configured to: determine a maximum quantity M of input data streams based on a quantity of users that corresponds to each input port and a maximum quantity of data streams that corresponds to each user; and group input data packets into the M input data streams.
 8. The network device according to claim 1, wherein the N queues are N output queues, and the M data streams are M output data streams; and correspondingly, the controller is further configured to set the N output queues based on a quantity of lower-level network devices.
 9. The network device according to claim 8, wherein the controller is further configured to: determine a maximum quantity M of output data streams based on the quantity of lower-level network devices, a maximum quantity of input ports of each lower-level network device, and a maximum quantity of data streams that corresponds to each input port of the lower-level network device; and group output data packets into the M output data streams.
 10. The network device according to claim 1, wherein the network device is a switching chip.
 11. The network device according to claim 1, wherein the network device is a switch.
 12. A method, comprising: buffering, by a network device, M data streams, wherein the network device comprises N queues in a buffer, and N is less than M; counting, by the network device, buffer quantities for M data streams in the N queues, wherein the network device comprises M counters, and the M counters are in a one-to-one correspondence with the M data streams; and when a count value on a first counter exceeds a corresponding threshold, sending, by the network device, pause indication information to an upper-level controller, wherein the pause indication information is used to instruct the upper-level controller to pause data packet sending, wherein the first counter is any one of the M counters.
 13. The method according to claim 12, further comprising: inserting, by the network device, the to-be-enqueued data packet into a corresponding queue, and controlling, by the network device, the first counter to update the count value, when the count value on the first counter is less than the corresponding threshold.
 14. The method according to claim 12, wherein the first counter is specifically configured to calculate a weighted average value of the count value and a length of the to-be-enqueued data packet, to obtain an updated count value on the first counter.
 15. The method according to claim 12, further comprising: scheduling, by the network device, in a data packet in any queue, and controlling, by the network device, a second counter corresponding to the scheduled data packet to update a count value.
 16. The method according to claim 12, further comprising: calculating, by the network device, a difference between the count value on the second counter and a length of the scheduled data packet, to obtain an updated count value on the second counter.
 17. The method according to claim 12, wherein the N queues are N input queues, and the M data streams are M input data streams; and the method further comprising: setting, by the network device, the N input queues based on a quantity of input ports of the network device and a maximum quantity of queues that corresponds to each input port.
 18. The method according to claim 17, wherein determining, by the network device, a maximum quantity M of input data streams based on a quantity of users that corresponds to each input port and a maximum quantity of data streams that corresponds to each user; and grouping, by the network device, input data packets into the M input data streams.
 19. The method according to claim 12, wherein the N queues are N output queues, and the M data streams are M output data streams; and the method further comprising: setting, by the network device, the N output queues based on a quantity of lower-level network devices.
 20. The method according to claim 19, further comprising, determining, by the network device, a maximum quantity M of output data streams based on the quantity of lower-level network devices, a maximum quantity of input ports of each lower-level network device, and a maximum quantity of data streams that corresponds to each input port of the lower-level network device; and grouping, by the network device, output data packets into the M output data streams. 